<?php
/**
 * The world of warcraft armory library was created by Marc Binder. The called
 * product will be deployed by Tof Technologies, Germany. All sources contain to 
 * the New BSD Licence. Self created extensions can be contained in the hall of 
 * fame. So the community has the chance to get a overview of all parsers and
 * handlers, which are really effective.
 * 
 * Get more informations:
 * http://code.google.com/p/warcraftarmory/
 * 
 * @author      Marc Binder <marcandrebinder@gmail.com>
 * @copyright   (c) Tof Technologies, Germany - 2010
 * @license     New BSD Licence
 * @package     Wow_Armory
 * @version     $Id$
 */

/**
 * Wow_Armory_Core_Handler_Abstract
 * 
 * @category    Wow_Armory
 * @package     Core
 * @subpackage  Handler Abstract
 * @example     n/A
 */
abstract class Wow_Armory_Core_Handler_Abstract
{
    
    const CHARACTER   = 'character';
    const STATISTIC   = 'statistic';
    const ACHIEVEMENT = 'achievement';
    const REPUTATION  = 'reputation';
    const TALENT      = 'talent';
    const GUILD       = 'guild';
    
    /**
     * Contains the result as array.
     * 
     * @var array
     */
    protected $_results = array();
    
    /**
     * Parse the result.
     * 
     * ----------
     * ATTENTION:
     * ----------
     * PLEASE OVERWRITE THIS METHOD WITH YOU OWN PARSE METHOD.
     * 
     * @see    parent
     * @throws Wow_Armory_Exception '', 1018
     * @return void
     */
    public function parse()
    {
        throw new Wow_Armory_Exception('', 1018);
    }
    
    /**
     * Sets a value by key.
     * 
     * @param  string $key
     * @param  mixed $value
     * @return void
     */
    public function __set($key, $value)
    {
        $this->_results[$key] = $value;
    }
    
    /**
     * Gets a value by string.
     * 
     * @param  string $key
     * @return mixed|null
     */
    public function __get($key)
    {
        if (isset($this->_results[$key])) {
            return $this->_results[$key];
        }
        
        return null;
    }
    
    /**
     * Parse the reuslts.
     * 
     * @param  array $results
     * @return void
     */
    protected function _toResults(Array $results)
    {
        foreach ($results as $name => $item) {
            $this->_results[$name] = $item;
        }
    }
    
}